package servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public LoginServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String uname = "jason";
		
		User user = new User();
		user.setId(1);
		user.setName("Jason");
		request.setAttribute("name", uname);
		request.setAttribute("u", user);
		
		User user2 = new User();
		user2.setId(2);
		user2.setName("jason2");
		request.getSession().setAttribute("u", user2);
		
		
		List<User> us=new ArrayList<User>();
		for(int i=0;i<10;i++){
			User uu=new User();
			uu.setId(i);
			uu.setName("John"+i);
			uu.setSal(345.67);
			uu.setBirth(new Date());
			uu.setSex(true);
			us.add(uu);
		}
		us.get(4).setSex(false);
		
		request.setAttribute("us", us);
		System.out.println("login...");
		request.getRequestDispatcher("show.jsp").forward(request, response);
		
	}

}
